package com.coocaa.ops.admin.v1.auth.sys.biz.impl;

import com.coocaa.ops.admin.v1.auth.sys.biz.ISysUserRoleBiz;
import com.coocaa.ops.admin.v1.auth.sys.mapper.ISysUserRoleMapper;
import com.coocaa.ops.common.core.base.BaseBizImpl;
import com.coocaa.ops.common.core.biz.auth.entity.SysUserRoleEntity;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author bijiahao
 * @date : 2019/3/18.
 * @description
 */
@Service
public class SysUserRoleBizImpl extends BaseBizImpl<ISysUserRoleMapper, SysUserRoleEntity> implements ISysUserRoleBiz {

    /**
     * 批量保存 用户角色
     *
     * @param userId
     * @param userRoles
     * @return
     */
    @Override
    public void saveBatch(Integer userId, List<SysUserRoleEntity> userRoles) {
        getMapper().deleteByUserId(userId);
        if (CollectionUtils.isNotEmpty(userRoles)) {
            getMapper().addBatch(userRoles);
        }
    }
}
